from flask import Flask
from extensions import mysql  # 从 extensions 导入 mysql 实例

from fraud import fraud
from login import login_app

def create_app():
    app = Flask(__name__)
    #  通过  app.register_blueprint()  将其他的flask注册到app中
    app.register_blueprint(fraud, url_prefix='')
    app.register_blueprint(login_app, url_prefix='')
    app.secret_key = 'njit'

    # MySQL 配置
    app.config['MYSQL_HOST'] = '106.14.137.132'
    app.config['MYSQL_USER'] = 'root'
    app.config['MYSQL_PASSWORD'] = 'zx20040714'
    app.config['MYSQL_DB'] = 'bsproject'

    # 初始化 MySQL
    mysql.init_app(app)
    return app

if __name__ == '__main__':
    app = create_app()
    app.run(debug=True, port=5000)
